package com.gsdse.controller;

import com.gsdse.pojo.ReturnData;
import com.gsdse.service.ExportExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class ExportExcelController {

    @Autowired
    ExportExcelService exportExcelService;

    @GetMapping("/getDepartmentApply")
    public ReturnData getDepartmentApply(@RequestParam("key") String key,@RequestParam("deptId") String deptId,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime, HttpServletResponse response) throws IOException {
        ReturnData returnData = new ReturnData();
        if(!("wlyfbyyds".equals(key))){
            returnData.setCode(1);
            returnData.setMsg("密钥错误！");
            return returnData;
        }

        if(deptId.isEmpty()){
            returnData.setCode(1);
            returnData.setMsg("参数不合法");
            return returnData;
        }
        return exportExcelService.getDepartmentApply(deptId,startTime,endTime,response);

    }
}
